import Taro, { Component } from "@tarojs/taro";
import { View, Button, Text, Image } from "@tarojs/components";
import { connect } from "@tarojs/redux";

class Available extends Component {
  state = {
    imgUrls: [
      {
        type: 0,
        img: "tixian",
        title: "提现"
      },
      {
        type: 1,
        img: "daodian",
        title: "客户到店"
      },
      {
        type: 2,
        img: "chengjiao",
        title: "客户成交"
      },
      {
        type: 3,
        img: "dianji",
        title: "点击量"
      }
    ]
  };

  findRecordForType(type) {
    const temp = this.state.imgUrls.filter(item => item.type === type);
    return temp[0];
  }

  render() {
    const { item } = this.props;
    const { img, title: typename } = this.findRecordForType(item.type);
    return (
      <View className="account-record">
        <View className="record-detail">
          <Image
            style="width:22px;height:22px;"
            src={require("../../assets/img/" + img + ".png")}
          />
          <View className="record-info">
            <View className="record-title-list">
              <Text className="record-font record-title">{item.des}</Text>
              <Text className="record-font">{item.money}</Text>
            </View>
            <View className="record-status-title">
              <Text className="status-font">{typename}</Text>
            </View>
            <View className="record-date">
              <Text className="record-date-font">{item.ctime}</Text>
            </View>
          </View>
        </View>
      </View>
    );
  }
}
export default Available;
